<template>
  <div class="data_list">
    <!-- 按钮 -->
    <div class="btns">
      <el-button @click="toAdd" size="small" type="primary">上报</el-button>
    </div>
    <!-- 列表 -->
    <el-table :data="epidemics.list" size="small">
      <el-table-column label="序号" type="index" :index="1"></el-table-column>
      <el-table-column label="国" prop="country"  width="120"></el-table-column>
      <el-table-column label="省" prop="province"  width="100"></el-table-column>
      <el-table-column label="市" prop="city"  width="100"></el-table-column>
      <el-table-column label="区" prop="area"  ></el-table-column>
      <el-table-column label="新增确诊" prop="confirmed" align="center" width="80"></el-table-column>
      <el-table-column label="疑似" align="center" width="60">
        <template v-slot:default="scope">
          <el-tag type="warning" size="mini">{{scope.row.suspected}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="死亡" align="center" width="60">
        <template v-slot:default="scope">
          <el-tag type="info" size="mini">{{scope.row.dead}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="治愈" align="center" width="60">
        <template v-slot:default="scope">
          <el-tag type="success" size="mini">{{scope.row.cure}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="重症" align="center" width="60">
        <template v-slot:default="scope">
          <el-tag type="danger" size="mini">{{scope.row.severe}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="境外输入" prop="outside" align="center" width="80"></el-table-column>
      <el-table-column label="上报时间" align="center" width="150" >
        <template v-slot:default="scope">
          {{scope.row.inputTime | fmtDate}}
        </template>
      </el-table-column>
    </el-table>
    <!-- 列表 -->
    <!-- 分页 -->
    <el-pagination
      v-if="epidemics.total > param.pageSize"
      layout="prev, pager, next"
      @current-change="currentChangeHandler"
      :current-page="param.page"
      :page-size="param.pageSize"
      :total="epidemics.total">
    </el-pagination>
   
    <!-- /分页 -->
  </div>
</template>

<script>
import {get} from '@/utils/request'

export default {
  data(){
    return {
      param:{
        page:1,
        pageSize:10
      },
      epidemics:{}
    }
  },
  created(){
    this.loadEpidemicData();
  },
  methods:{
    //加载所有疫情数据
    loadEpidemicData(){
      let url = "/epidemic/pageQuery";
      get(url,this.param).then(response => {
        this.epidemics = response.data;
      })
    },
    // 去上报
    toAdd(){
      this.$router.push({
        path:'/data/input'
      })
    },
    currentChangeHandler(page){
      this.param.page = page;
      this.loadEpidemicData();
    }
  }
}
</script>